We use an 18' x 9' mosaic of ACS images covering the entire large-scale structure around the X-ray luminous cluster MACSJ0717.5 (z=0.545) to study the morphology of galaxies at the cluster redshift. We find the global fraction of morphological types of galaxies to be consistent with results in the literature. Interestingly, we find that the fraction of S0s also correlates with local galaxy density, in contrast to the findings of a study of the cores of 10 clusters at similar redshift by Dressler et al. We suggest that this apparent inconsistency is due to differences in the spatial coverage around clusters, which is supported by the fact that the correlation disappears for S0s within a radius of 0.6R_200 of MACSJ0717. We interpret this result as evidence of the morphology-density relation being caused by a combination of morphological transformation triggered by galaxy-galaxy interactions, and effects related to the formation and evolution of large-scale structure. In environments of low to intermediate density, where galaxy-galaxy interactions are frequent and efficient, the observed pronounced morphology-density relation for S0s reflects the density dependence of the interaction cross section. In clusters, however, the correlation disappears for S0s, as the much higher galaxy velocities in clusters not only lower the interaction cross section, but also cause a spatial redistribution of galaxies that all but destroys such a correlation. This argument does not hold for elliptical galaxies in clusters which, having formed much earlier, have settled into the large-scale cluster potential; hence the morphology-density relation for cluster ellipticals may reflect primarily the state of advanced dynamical relaxation of this population within the cluster rather than a causal link to the environment responsible for the morphological transformation of galaxies.